﻿@model IPropertyMetadata
@switch (Model.Type)
{
    case System.ComponentModel.DataAnnotations.CustomDataType.Date:
        <div class="input-group">
            <input type="date" class="form-control span2" id="Search_@(Model.ClrName)_Start" name="Search.@(Model.ClrName).Start" value="@Context.Request.Query["Search." + Model.ClrName + ".Start"]"/>
            <span class="input-group-addon">至</span>
            <input type="date" class="form-control span2" id="Search_@(Model.ClrName)_End" name="Search.@(Model.ClrName).End" value="@Context.Request.Query["Search." + Model.ClrName + ".End"]"/>
        </div>
        break;
    case System.ComponentModel.DataAnnotations.CustomDataType.DateTime:
        <div class="input-group">
            <input type="datetime-local" class="form-control span2" id="Search_@(Model.ClrName)_Start" name="Search.@(Model.ClrName).Start"  value="@Context.Request.Query["Search." + Model.ClrName + ".Start"]"/>
            <span class="input-group-addon">至</span>
            <input type="datetime-local" class="form-control span2" id="Search_@(Model.ClrName)_End" name="Search.@(Model.ClrName).End" value="@Context.Request.Query["Search." + Model.ClrName + ".End"]" />
        </div>
        break;
    case System.ComponentModel.DataAnnotations.CustomDataType.Currency:
    case System.ComponentModel.DataAnnotations.CustomDataType.Integer:
    case System.ComponentModel.DataAnnotations.CustomDataType.Number:
        <div class="input-group">
            <input type="number" class="form-control span2" id="Search_@(Model.ClrName)_Start" name="Search.@(Model.ClrName).Start"  value="@Context.Request.Query["Search." + Model.ClrName + ".Start"]"/>
            <span class="input-group-addon">至</span>
            <input type="number" class="form-control span2" id="Search_@(Model.ClrName)_End" name="Search.@(Model.ClrName).End"  value="@Context.Request.Query["Search." + Model.ClrName + ".End"]"/>
        </div>
        break;
    case System.ComponentModel.DataAnnotations.CustomDataType.Other:
        if (Model.CustomType == "Enum")
        {
            Wodsoft.ComBoost.Mvc.EntityExtensions.EnumItem[] items;
            if (Model.ClrType.GetTypeInfo().IsGenericType)
            {
                items = Wodsoft.ComBoost.Mvc.EntityExtensions.EnumAnalyze(Model.ClrType.GetGenericArguments()[0]);
            }
            else
            {
                items = Wodsoft.ComBoost.Mvc.EntityExtensions.EnumAnalyze(Model.ClrType);
            }
            <select name="Search.@Model.ClrName" class="form-control">
                <option value="" selected="selected">请选择…</option>
                @for (int s = 0; s < items.Length; s++)
                {
                    <option value="@items[s].Value">@items[s].Name</option>
                }
            </select>
        }
        else
        {
            <input type="text" class="form-control" name="Search.@Model.ClrName" />
        }
        break;
    case System.ComponentModel.DataAnnotations.CustomDataType.Boolean:
        <select class="form-control" name="Search.@Model.ClrName">
            <option value="" selected="selected"></option>
            <option value="True">是</option>
            <option value="False">否</option>
        </select>
        break;
    case System.ComponentModel.DataAnnotations.CustomDataType.Gender:
        <select class="form-control" name="Search.@Model.ClrName">
            <option value="" selected="selected"></option>
            <option value="True">男</option>
            <option value="False">女</option>
        </select>
        break;
    default:
        <input type="text" class="form-control" name="Search.@Model.ClrName"  value="@Context.Request.Query["Search." + Model.ClrName]"/>
        break;
}